//////////////////////////////////////////////////////////////////////////////////
//
//	TK Subtract Kills
//		- Version 1.3
//		- 04.18.2008
//		- diamond-optic
//
//////////////////////////////////////////////////////////////////////////////////
//
// Information:
//
// 	- When someone TKs, they will lose kills...
//
// CVARS: 
//
//	  amx_tk_subtract_kills "1"	//Turn ON(1)/OFF(0)
//
//	  amx_tk_subtract_num "5"	//Number of kills to subtract
//
//	  amx_tk_subtract_msg "1"	//Message Mode
//						//"0" = No Message
//						//"1" = Chat Message
//						//"2" = Center Message
//						//"3" = Hud Message
//
//	  amx_tk_subtract_msg_who "1"	//Who will see the messages
//						//"0" = No One
//						//"1" = Everyone
//						//"2" = TKer Only
//
// Extra:
//
//	- Just a very simple plugin made for a request on IRC
//
// Changelog:
//
//	 - 06.24.2006 Version 1.0
//		Initial Release
//
//	 - 06.25.2006 Version 1.1
//		Added Messages
//
//	 - 12.25.2006 Version 1.2
//		fixed an error with the native
//		added public cvar for tracking
//
//	 - 04.18.2008 Version 1.3
//		Updated public cvar format
//		Replaced if statements with switches
//		Cleaned up code a little bit
//
//////////////////////////////////////////////////////////////////////////////////

#include <amxmodx>
#include <fun>

#define VERSION "1.3"
#define SVERSION "v1.3 - by diamond-optic (www.AvaMods.com)"

new p_number,p_on,p_msg_type,p_msg_who

public plugin_init()
{
	register_plugin("TK Subtract Kills",VERSION,"diamond-optic")
	register_cvar("amx_tk_subtract_kills_stats",SVERSION,FCVAR_SERVER|FCVAR_SPONLY)
	
	register_event("DeathMsg","funcDeath","a")
	
	p_on = register_cvar("amx_tk_subtract_kills","1")
	p_number = register_cvar("amx_tk_subtract_num","5")
	p_msg_type = register_cvar("amx_tk_subtract_msg","1")
	p_msg_who = register_cvar("amx_tk_subtract_msg_who","1")
}

public funcDeath()
{
	new killer = read_data(1)
	
	if(!is_user_connected(killer) || !get_pcvar_num(p_on))
		return PLUGIN_HANDLED
		
	new victim = read_data(2)
	
	if(killer != victim && get_user_team(killer) == get_user_team(victim))
		{
		set_user_frags(killer,get_user_frags(killer)-get_pcvar_num(p_number))
		
		new killer_name[33],victim_name[33]
		get_user_name(killer,killer_name,32)
		get_user_name(victim,victim_name,32)
		
		new who = get_pcvar_num(p_msg_who)
		
		switch(get_pcvar_num(p_msg_type))
			{
			case 1: {
				switch(who)
					{
					case 1: client_print(0,print_chat,"* %s has lost %d kills for TKing %s *",killer_name,get_pcvar_num(p_number),victim_name)
					case 2: client_print(killer,print_chat,"* You have lost %d kills for TKing %s *",get_pcvar_num(p_number),victim_name)
					}
				}
			case 2: {
				switch(who)
					{
					case 1: client_print(0,print_center,"* %s has lost %d kills for TKing %s *",killer_name,get_pcvar_num(p_number),victim_name)
					case 2: client_print(killer,print_center,"* You have lost %d kills for TKing %s *",get_pcvar_num(p_number),victim_name)
					}
				}
			case 3:
				{
				switch(who)
					{
					case 1:	{
						set_hudmessage(random_num(0,255), random_num(0,255), random_num(0,255), 0.01, 0.70, 0, 0.0, 3.0, 0.0, 0.0, 4)
						show_hudmessage(0, "* %s has lost %d kills for TKing %s *",killer_name,get_pcvar_num(p_number),victim_name)
						}
					case 2:	{
						set_hudmessage(random_num(0,255), random_num(0,255), random_num(0,255), 0.01, 0.70, 0, 0.0, 3.0, 0.0, 0.0, 4)
						show_hudmessage(killer, "* You have lost %d kills for TKing %s *",get_pcvar_num(p_number),victim_name)
						}
					}
				}
			}
		}
		
	return PLUGIN_CONTINUE
}
